package com.bolehui.web;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bolehui.base.result.Result;
import com.bolehui.domain.po.Portfolio;
import com.bolehui.domain.vo.PortFolioVO;
import com.bolehui.service.PortfolioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chendongjie
 * @since 2025-03-18
 */
@RestController
@RequestMapping("/portfolio")
public class PortfolioController {

    @Autowired
    private PortfolioService portfolioService;

    @RequestMapping(params = "action=savePortf")
    public Result savePortfolio(@RequestBody PortFolioVO portFolioVO, @RequestParam Long userId){
        return portfolioService.savePortf(portFolioVO, userId);
    }

    @RequestMapping(params = "action=list")
    public Result list(Long userId){
        return Result.success(portfolioService.list(new QueryWrapper<Portfolio>().eq("candidate_id", userId)));
    }

    @RequestMapping(params = "action=update")
    public Result update(@RequestBody PortFolioVO portFolioVO, Long userId){
        return portfolioService.update(portFolioVO, userId);
    }

    @RequestMapping(params = "action=delete")
    public Result delete(Long id){
        return Result.success(portfolioService.removeById(id));
    }
}

